package windbell.domain.risk;

import com.google.common.base.Objects;
import edu.fudan.langlab.domain.task.TSKRoutineProtocal;
import edu.fudan.langlab.domain.task.TSKRoutineTaskGenerator;
import edu.fudan.mylang.pf.EntityAdaptor;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import windbell.domain.risk.IHasRiskCheckTemplate;
import windbell.domain.risk.RiskCheckGenerator;
import windbell.domain.risk.RiskCheckTemplate;
import windbell.domain.risk.RiskCheckTemplateItem;
import windbell.domain.risk.proxy.TSKRoutineProtocalToIHasRiskCheckTemplateAdaptorProxy;

public class TSKRoutineProtocalToIHasRiskCheckTemplateAdaptor extends EntityAdaptor<TSKRoutineProtocal> implements IHasRiskCheckTemplate {
  public TSKRoutineProtocalToIHasRiskCheckTemplateAdaptor() {
    super();
  }
  
  public TSKRoutineProtocalToIHasRiskCheckTemplateAdaptor(final TSKRoutineProtocal adaptee) {
    this.adaptee = adaptee;
  }
  
  public TSKRoutineProtocalToIHasRiskCheckTemplateAdaptorProxy toProxy() {
    return new TSKRoutineProtocalToIHasRiskCheckTemplateAdaptorProxy(adaptee.toProxy());
  }
  
  public RiskCheckTemplate getCheckTemplate() {
    RiskCheckTemplate _xblockexpression = null;
    {
      final TSKRoutineTaskGenerator generator = this.adaptee.getGenerator();
      RiskCheckTemplate _switchResult = null;
      boolean _matched = false;
      if (!_matched) {
        if (generator instanceof RiskCheckGenerator) {
          final RiskCheckGenerator _riskCheckGenerator = (RiskCheckGenerator)generator;
          _matched=true;
          RiskCheckTemplate _checkTemplate = _riskCheckGenerator.getCheckTemplate();
          _switchResult = _checkTemplate;
        }
      }
      if (!_matched) {
        _switchResult = null;
      }
      _xblockexpression = (_switchResult);
    }
    return _xblockexpression;
  }
  
  public Collection<RiskCheckTemplateItem> getRiskCheckTemplateItems() {
    Collection<RiskCheckTemplateItem> _xifexpression = null;
    RiskCheckTemplate _checkTemplate = this.getCheckTemplate();
    boolean _notEquals = (!Objects.equal(_checkTemplate, null));
    if (_notEquals) {
      RiskCheckTemplate _checkTemplate_1 = this.getCheckTemplate();
      Collection<RiskCheckTemplateItem> _checkList = _checkTemplate_1.getCheckList();
      _xifexpression = _checkList;
    } else {
      ArrayList<RiskCheckTemplateItem> _newArrayList = CollectionLiterals.<RiskCheckTemplateItem>newArrayList();
      _xifexpression = _newArrayList;
    }
    return _xifexpression;
  }
}
